<include file="public@header"/>
<style>
.table img{
	max-width:100px;
	max-height:100px;
}
.textArea textarea{
	width:90%;padding:3%;height:80%;margin:0 auto;margin-top:30px;
	margin-left: 2%;
}
.textArea_btn{
	text-align: right;
	margin-top: 30px;
}
.textArea_btn input{
	margin-right: 30px;
}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a >等待审核列表</a></li>

		</ul>
		
		<form class="well form-inline margin-top-20" method="post" action="{:url('Video/index')}">
			排序：
			<select class="select_2 form-control" name="ordertype">
				<option value="">默认</option>
				<option value="1" <if condition="input('request.ordertype') eq 1">selected</if> >评论数排序</option>		
				<option value="2" <if condition="input('request.ordertype') eq 2">selected</if> >点赞数排序</option>
				<option value="3" <if condition="input('request.ordertype') eq 3">selected</if> >分享数排序</option>
					
			</select>

			
			关键字： 
			<input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}" placeholder="视频ID/会员ID">
			<input class="form-control" type="text" name="keyword1" style="width: 200px;" value="{:input('request.keyword1')}" placeholder="视频标题">
			<input class="form-control" type="text" name="keyword2" style="width: 200px;" value="{:input('request.keyword2')}" placeholder="用户名称">
			<input type="submit" class="btn btn-primary" value="搜索">
			<a class="btn btn-danger" href="{:url('Admin/Video/index')}">清空</a>
		</form>		
		
		<form method="post" class="js-ajax-form">
			<div class="table-actions">
				<button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('Video/setBatchStatus',['status'=>1])}"
                        data-subcheck="true">批量通过
                </button>
                <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('Video/setBatchStatus',['status'=>2])}"
                        data-subcheck="true">批量拒绝
                </button>
                <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('Video/setBatchDel')}"
                        data-subcheck="true">批量删除
                </button>
                <p class="help-block" style="font-weight: bold;">批量操作请谨慎</p>
            </div>
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th width="16">	
                            <label>
                                <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                            </label>	
                        </th>
						<th align="center">ID</th>
						<th>会员昵称（ID）</th>
						<th style="max-width: 300px;">标题</th>
						<th>图片</th>
						<th>点赞数</th>
						<th>评论数</th>
						<th>分享数</th>
						<th>视频状态</th>
						<th>上下架状态</th>
						<th>发布时间</th>
						<th align="center">{:lang('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
					<php>$isdel=array("0"=>"上架","1"=>"下架");$status=array("0"=>"待审核","1"=>"通过","2"=>"不通过");</php>
					<foreach name="lists" item="vo">
					<tr>
						<td>
                            <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}">
                        </td>
						<td align="center">{$vo.id}</td>
						<td>{$vo['userinfo']['user_nicename']} ({$vo['uid']})</td>
						<td style="max-width: 300px;">{$vo['title']}</td>
						<td><img src="{:get_upload_path($vo['thumb'])}" class="imgtip" /></td>
						<td>{$vo['likes']}</td>
						<td>{$vo['comments']}</td>
						<td>{$vo['shares']}</td>
						<td>{$status[$vo['status']]}</td>
						<td>{$isdel[$vo['isdel']]}</td>
						<td>{:date('Y-m-d H:i:s',$vo['addtime'])}</td>
						<td align="center">
							<a class="btn btn-xs btn-primary" href="javascript:void(0)" onclick="videoListen({$vo['id']})" >观看</a>
							
							<a class="btn btn-xs btn-primary" href="{:url('Video/edit',array('id'=>$vo['id'],'from'=>'index'))}" >编辑</a>
							 <if condition="$vo['isdel'] eq '0'">
							
							<a class="btn btn-xs btn-primary" href="javascript:void (0)" onclick="commentlists({$vo['id']})" >评论列表</a>
						
							 <a class="btn btn-xs btn-danger" href="javascript:void (0)" onclick="del({$vo['id']})" >删除</a></if>
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
			<div class="table-actions">
				<button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('Video/setBatchStatus',['status'=>1])}"
                        data-subcheck="true">批量通过
                </button>
                <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('Video/setBatchStatus',['status'=>2])}"
                        data-subcheck="true">批量拒绝
                </button>
                <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('Video/setBatchDel')}"
                        data-subcheck="true">批量删除
                </button>
                <p class="help-block" style="font-weight: bold;">批量操作请谨慎</p>
            </div>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js?t={$time}"></script>
	<script src="__STATIC__/layer/layer.js"></script>
	<script type="text/javascript">


		var del_status=0;

		function del(id){
			var p={$p};

			layer.open({
			  type: 1,
			  title:"是否确定将该视频删除",
			  skin: 'layui-layer-rim', //加上边框
			  area: ['30%', '30%'], //宽高
			  content: '<div class="textArea"><textarea id="del_reason" maxlength="50" placeholder="请输入删除原因,最多50字" /> </div><div class="textArea_btn" ><input type="button" id="delete" value="删除" onclick="del_submit('+id+','+p+')" /><input type="button" id="cancel" onclick="layer.closeAll();" value="取消" /></div>'
			});
		}

		function del_submit(id,p){

			var reason=$("#del_reason").val();

			if(del_status==1){
				return;
			}

			del_status=1;

			$.ajax({
				url: '/admin/video/setXiajia.html',
				type: 'POST',
				dataType: 'json',
				data: {id:id,reason: reason},
				success:function(data){
					var code=data.code;
					if(code!=0){
						layer.msg(data.msg);
						return;
					}

					del_status=0;

					if(data.msg=='您没有访问权限！'){
						layer.msg(data.msg);
						return;
					}

					
					//设置按钮不可用
					$("#delete").attr("disabled",true);
					$("#cancel").attr("disabled",true);

					layer.msg("删除成功",{icon: 1,time:1000},function(){
						layer.closeAll();
						<!-- location.href='/admin/video/nopassindex.html&page='+p;  -->
						location.reload();
					});
				},
				error:function(e){
					$("#delete").attr("disabled",false);
					$("#cancel").attr("disabled",false);

					console.log(e);
				}
			});
			
			
		}

		/*获取视频评论列表*/
		function commentlists(videoid){
			layer.open({
				type: 2,
				title: '视频评论列表',
				shadeClose: true,
				shade: 0.8,
				area: ['60%', '90%'],
				content: '/admin/video/commentlists.html&videoid='+videoid 
			}); 
		}
	</script>

	<script type="text/javascript">
		function videoListen(id){
			layer.open({
			  type: 2,
			  title: '观看视频',
			  shadeClose: true,
			  shade: 0.8,
			  area: ['500px', '750px'],
			  content: '/admin/video/video_listen.html&id='+id
			}); 
		}
	</script>
</body>
</html>